const TOKEN_FILE = 'token'
const VERIFICATION_CODE_FILE = 'verification_code'
const OCR_FILE = `../screenshots/${VERIFICATION_CODE_FILE}`
const OUTPUT_FILE = `cypress/fixtures/${VERIFICATION_CODE_FILE}.json`

describe('MSKJ 管理后台', () => {
  it.skip('登录', () => {
    cy.visit('/#/login').then(() => {
      cy.intercept('*/login/captcha*').as('img')
      cy.wait('@img')

      // 截图验证码
      cy.screenshot('verification_code', {
        overwrite: true,
        clip: { x: 840, y: 360, width: 100, height: 45 },
      })

      // 调用百度的文字识别并以JSON格式保存识别后的内容
      cy.getBaiduOCR(OCR_FILE, OUTPUT_FILE)

      // 登录
      cy.fixture(VERIFICATION_CODE_FILE).then(data => {
        cy.get('[name="name"]').clear().type(data.username)
        cy.get('[name="pwd"]').clear().type(data.password)
        cy.get('[placeholder="Verification Code"]').type(data.code)
        cy.get('[type="button"]').click()

        cy.intercept('*/venue/list').as('success')
        cy.wait('@success')
      })
    })
  })
})
